﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;

namespace Katana.DataAccess
{
    public partial class Team
    {
        #region Members

        protected EntitySet<Lid> m_Leden;

        #endregion

        #region Properties

        public IQueryable<Lid> Leden
        {
            get
            {
                m_Leden = new EntitySet<Lid>(onAddLid, onRemoveLid);

                var leden = from l in KatanaContext.Context.Lids
                            join tl in KatanaContext.Context.TeamSpelers on l.LidID equals tl.LidID
                            where tl.TeamID == this.TeamID
                            select l;

                foreach (var l in leden)
                {
                    m_Leden.Add(l);
                }

                return leden;
            }
        }

        #endregion

        #region Properted methods

        protected void onAddLid(Lid lid)
        {
            TeamSpeler ts = new TeamSpeler();
            ts.TeamID = this.TeamID;
            ts.LidID = lid.LidID;

            //db.TeamSpelers.(ts);
        }
        protected void onRemoveLid(Lid lid)
        {

        }

        #endregion
    }
}
